package com.ruoyi.etp.controller;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.etp.domain.EtpCustomerServiceStats;
import com.ruoyi.etp.service.IEtpCustomerServiceStatsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户服务统计Controller
 *
 * @author xmj
 * @date 2025-09-09
 */
@RestController
@RequestMapping("/etp/etpCustomerServiceStats")
public class EtpCustomerServiceStatsController extends BaseController
{
    @Autowired
    private IEtpCustomerServiceStatsService etpCustomerServiceStatsService;

    /**
     * 查询客户服务统计列表
     */
    @PreAuthorize("@ss.hasPermi('etp:etpCustomerServiceStats:list')")
    @GetMapping("/list")
    public TableDataInfo list(EtpCustomerServiceStats etpCustomerServiceStats)
    {
        startPage();
        List<EtpCustomerServiceStats> list = etpCustomerServiceStatsService.selectEtpCustomerServiceStatsList(etpCustomerServiceStats);
        return getDataTable(list);
    }

    /**
     * 导出客户服务统计列表
     */
    @PreAuthorize("@ss.hasPermi('etp:etpCustomerServiceStats:export')")
    @Log(title = "客户服务统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EtpCustomerServiceStats etpCustomerServiceStats)
    {
        List<EtpCustomerServiceStats> list = etpCustomerServiceStatsService.selectEtpCustomerServiceStatsList(etpCustomerServiceStats);
        ExcelUtil<EtpCustomerServiceStats> util = new ExcelUtil<EtpCustomerServiceStats>(EtpCustomerServiceStats.class);
        util.exportExcel(response, list, "客户服务统计数据");
    }

    /**
     * 获取客户服务统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('etp:etpCustomerServiceStats:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(etpCustomerServiceStatsService.getById(id));
    }

    /**
     * 新增客户服务统计
     */
    @PreAuthorize("@ss.hasPermi('etp:etpCustomerServiceStats:add')")
    @Log(title = "客户服务统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EtpCustomerServiceStats etpCustomerServiceStats) {
        return toAjax(etpCustomerServiceStatsService.save(etpCustomerServiceStats));
    }

    /**
     * 修改客户服务统计
     */
    @PreAuthorize("@ss.hasPermi('etp:etpCustomerServiceStats:edit')")
    @Log(title = "客户服务统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EtpCustomerServiceStats etpCustomerServiceStats) {
        return toAjax(etpCustomerServiceStatsService.updateById(etpCustomerServiceStats));
    }

    /**
     * 删除客户服务统计
     */
    @PreAuthorize("@ss.hasPermi('etp:etpCustomerServiceStats:remove')")
    @Log(title = "客户服务统计", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(etpCustomerServiceStatsService.removeByIds(Arrays.asList(ids)));
    }
}
